package com.ogawa.projectcommon.utils;

import android.app.Activity;
import android.graphics.Color;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.blankj.utilcode.util.StringUtils;
import com.ogawa.base.R;

public class DataStatusViewUtils {

    public static final int NET_ERR = 1;
    public static final int DATA_EMPTY = 2;

    public static View getView(Activity activity,int status, String desc, int color,View.OnClickListener onClickListener){
        View emptyView = activity.getLayoutInflater().inflate(R.layout.view_no_data,null, false);
        FrameLayout view_no_data_rootback = emptyView.findViewById(R.id.view_no_data_rootback);
        view_no_data_rootback.setBackgroundColor(color);
        ImageView view_no_data_iv = emptyView.findViewById(R.id.view_no_data_iv);
        TextView view_no_data_desc_tv = emptyView.findViewById(R.id.view_no_data_desc_tv);
        TextView view_no_data_resetBt = emptyView.findViewById(R.id.view_no_data_resetBt);
        LinearLayout contentLL = emptyView.findViewById(R.id.contentLL);
        view_no_data_resetBt.setOnClickListener(onClickListener);
        if (onClickListener != null){
            view_no_data_resetBt.setVisibility(View.VISIBLE);
        }else {
            view_no_data_resetBt.setVisibility(View.GONE);
        }

        switch (status){

            case NET_ERR:{
                view_no_data_desc_tv.setText(R.string.status_net_err);
                view_no_data_iv.setImageResource(R.drawable.ic_empty_data);
                break;
            }
            case DATA_EMPTY:{
                view_no_data_desc_tv.setText(R.string.status_no_data);
                view_no_data_iv.setImageResource(R.drawable.ic_empty_data);
                break;
            }
            default:
                break;
        }
        if (!StringUtils.isEmpty(desc)){
            view_no_data_desc_tv.setText(desc);
        }

        return emptyView;
    }

    public static View getView(Activity activity,int status, String desc, View.OnClickListener onClickListener){
         return getView(activity,status, desc,Color.WHITE,onClickListener);
    }








}
